package architecture;

//ALU
public class ALU{
	MyInt src1;
	MyInt src2;
	MyInt result;
	//MyInt zero;
	MyInt ALUOp;
	void clockEvent(){
		switch(ALUOp.i){
		case 0x4:
			MyUtil.sll(src1,src2,result);
		case 0x6:
			MyUtil.srl(src1,src2,result);
		case 0x7:
			MyUtil.sra(src1,src2,result);
		case 0x20:
			MyUtil.add(src1,src2,result);
		case 0x21:
			MyUtil.addu(src1,src2,result);
		case 0x22:
			MyUtil.sub(src1,src2,result);
		case 0x23:
			MyUtil.subu(src1,src2,result);
		case 0x24:
			MyUtil.and(src1,src2,result);
		case 0x25:
			MyUtil.or(src1,src2,result);
		case 0x26:
			MyUtil.xor(src1,src2,result);
		case 0x28:
			MyUtil.seq(src1,src2,result);
		case 0x29:
			MyUtil.sne(src1,src2,result);
		case 0x2a:
			MyUtil.slt(src1,src2,result);
		case 0x2b:
			MyUtil.sgt(src1,src2,result);
		case 0x2c:
			MyUtil.sle(src1,src2,result);
		case 0xe:
			MyUtil.mult(src1,src2,result);
		case 0xf:
			MyUtil.div(src1,src2,result);
		case 0x16:
			MyUtil.multu(src1,src2,result);
		case 0x17:
			MyUtil.divu(src1,src2,result);
		}
		/*if(result.i==0)
			zero.i=1;
		else zero.i=0;*/
	}
	void dump(){
		System.out.println("--------");
		System.out.println("ALU:");
		System.out.println("src1:"+src1);
		System.out.println("src2:"+src2);
		System.out.println("ALUOp:"+ALUOp);
		System.out.println("result:"+result);
		System.out.println("--------");
	}
}